from dataclasses import dataclass
from typing import Any, Protocol

from src.application.proxy.dto.proxies import ProxyDTOs
from src.application.proxy.dto.proxy import ProxyDTO
from src.application.server.enums import ServerPrivacy, ServerType
from src.domain.common.constants import Empty, OrderBy
from src.domain.server.entities.category import CategoryEntity
from src.domain.user.aggregates import UserAggregate


@dataclass(frozen=True)
class GetProxiesFilters:
    offset: int | Empty = Empty.UNSET
    limit: int | Empty = Empty.UNSET
    proxy_type: ServerType | Empty = Empty.UNSET
    proxy_privacy: ServerPrivacy | Empty = Empty.UNSET
    country_id: int | Empty = Empty.UNSET
    provider_id: int | Empty = Empty.UNSET
    site_id: int | Empty = Empty.UNSET
    category_id: int | Empty = Empty.UNSET
    user_tg_id: int | Empty = Empty.UNSET
    order_by: OrderBy = OrderBy.ASC


class ProxyReader(Protocol):
    async def get_proxy_by_id(self, proxy_id: int) -> ProxyDTO:
        raise NotImplementedError

    async def get_all_proxies(self) -> list[ProxyDTO]:
        raise NotImplementedError

    async def get_available_proxies(
        self, user: UserAggregate, category: CategoryEntity, filters: GetProxiesFilters
    ) -> list[ProxyDTOs]:
        """Получаем доступные прокси"""
        raise NotImplementedError

    async def get_server_proxies(
        self, proxies: list[ProxyDTO] | list[dict[str, Any]], new_proxies: list[ProxyDTO] | None = None
    ) -> dict[int, list[tuple[ProxyDTO, ProxyDTO]] | list[ProxyDTO]]:
        raise NotImplementedError
